<template>
	<view>
		<view class="uni-padding-wrap uni-common-mt" style="padding-left: 0px; padding-right: 0px;">
			<view class="uni-flex uni-column">
				
				<view class="top">
					<view class="userinfo">
						
						<image :src="data.img" mode="widthFix" class="header-image" style="width: 150rpx; height: 150rpx;"></image>
						<view class="info" v-if="data.phone=='点击登录'" @tap="goLogin" >
							<view class="phone" style="font-size: 32rpx;color: #ffaa7f;">
								{{data.phone}}
							</view>
						</view>
						<view class="info" v-else>
							<view class="phone" style="font-size: 32rpx;">
								{{data.phone}}
							</view>
							<view class="lev">
								{{levelName}}
							</view>
						</view>
						
					</view>
				</view>
				
				
				<view class="indexback">
					
				<!-- 我的收益 -->
					<view class="profit">
						<view class="profit-content">
							<view class="title">
								<view class="title-c">
									<view class="title-con">
										我的收益
									</view>
									<view class="eye-pic" :class="[!show ? '': 'unshow']" @tap="eye"></view>
								</view>
								<view class="tixian" @tap="toGorule">提 现</view>
								
							</view>
							
							<view class="choose">
								<!-- <view class="uni-flex uni-row"> -->
									
									<view class="money-a" >
											<view class="money-b" style="font-size: 30rpx;">累计收益（元）</view>
											<view class="money-c" v-if="!show">{{data.total_num}}</view>
											<view class="money-c" v-else>*****</view>
									</view>
									<view class="money-a">
											<view class="money-b" style="font-size: 30rpx;">可提现（元）</view>
											<view class="money-c" style="color:#ffa500 ;" v-if="!show">{{data.balance}}</view>
											<view class="money-c" style="color:#ffa500 ;" v-else>*****</view>
									</view>
								<!-- </view> -->
							</view>
							
							<view class="schoose">
								<!-- <view class="uni-flex uni-row"> -->
									
									<view class="money-d">
										<view class="money-e" style="font-size: 25rpx;">昨日总收益（元）</view>
										<view class="money-f" v-if="!show">{{jia}}</view>
										<view class="money-f" v-else>***</view>
									</view>
									<view class="money-d" @tap="toZuoShare">
											<view class="money-e" style="font-size: 25rpx;">昨日分润（元）</view>
											<view class="money-f" v-if="!show">{{data.friend_profit}}</view>
											<view class="money-f" v-else>***</view>
									</view>
									<view class="money-g" @tap="toZuo">
										<view class="money-e" style="font-size: 25rpx">昨日收益（元）</view>
										<view class="money-f" v-if="!show">{{data.self_profit}}</view>
										<view class="money-f" v-else>***</view>	
									</view>
								<!-- </view> -->
									
							</view>
							
						</view>
					</view>
					
					<!--设备-->
					<view class="equipment">
						<view class="equipment-content">
							
							<view class="schoose">
									
								<view class="money-d" >
										<view class="money-e" style="font-size: 25rpx;">总设备（台）</view>
										<view class="money-f">{{data.self+data.euqs}}</view>
								</view>
								<view class="money-d" @tap="toEqu(4,0)">
										<view class="money-e" style="font-size: 25rpx;">自有设备（台）</view>
										<view class="money-f">{{data.self}}</view>
								</view>
								<view class="money-g"  @tap='togengduo'>
										<view class="money-e" style="font-size: 25rpx;">伙伴设备（台)</view>
										<view class="money-f">{{data.euqs}}</view>
								</view>
									
							</view>
							
						</view>
					</view>
				
					<!-- 订单状态 -->
					<view class="order" >
						<view class="order-box">
							<view class="chooses" >
								<view class="bind-box" style="text-align: center; " @tap="goOrder(1)">
										<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/payment.png" mode="widthFix" style="width: 72rpx; height: 72rpx;margin-bottom: 10rpx;"></image>
										<view style="font-size: 26rpx;">待付款</view>
								</view>
								<view class="bind-box" style="text-align: center;"  @tap="goOrder(2)">
										<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/Nshipped.png" mode="widthFix" style="width: 72rpx; height: 72rpx;margin-bottom: 10rpx;"></image>
										<view style="font-size: 26rpx;">待发货</view>
								</view>
								<view class="bind-box" style="text-align: center;"  @tap="goOrder(3)">
										<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/delivery.png" mode="widthFix" style="width: 72rpx; height: 72rpx;margin-bottom: 10rpx;"></image>
										<view style="font-size: 26rpx;">已发货</view>
								</view>
								<view class="bind-box" style="text-align: center;" @tap="goOrder(4)">
										<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/After_sales.png" mode="widthFix" style="width: 72rpx; height: 72rpx;margin-bottom: 10rpx;"></image>
										<view style="font-size: 26rpx;">售后</view>
								</view>
								<view class="bind-box" style="text-align: center;" @tap="goOrder(0)">
										<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/All.png" mode="widthFix" style="width: 72rpx; height: 72rpx;margin-bottom: 10rpx;" ></image>
										<view style="font-size: 26rpx;">全部订单</view>
								</view>
							</view>
						</view>
					</view>
				
				
				
				<!-- <view class="list-content">
				
					<view class="lists" @tap="invite">
						<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/Friend.png" mode="widthFix" class="img-one"></image>
						<view class="con">
							邀请好友
						</view>
						<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/Vector.png" mode="widthFix" class="img-two"></image>
					</view>
				</view> -->
					
				<view class="list-content">
					<view class="lists" @tap="goConfig">
						<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/set.png" mode="widthFix" class="img-one"></image>
						<view class="con">
							设置
						</view>
						<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/Vector.png" mode="widthFix" class="img-two"></image>
					</view>
				</view>
				
				<!-- <view class="list-content">
					<view class="lists" @tap="about">
						<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/About.png" mode="widthFix" class="img-one"></image>
						<view class="con">
							关于我们
						</view>
						<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/Vector.png" mode="widthFix" class="img-two"></image>
					</view>
				</view> -->
				
				<view class="list-content">	
					<view class="lists" @tap="signout">
						<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/quit.png" mode="widthFix" class="img-one"></image>
						<view class="con">
							退出登录
						</view>
						<image src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/Vector.png" mode="widthFix" class="img-two"></image>
					</view>
				</view>	
					
					
				</view>
			
			</view>
		</view>

		
	</view>
</template>

<script>
	// import {mapState} from 'vuex'
	let App = getApp()
	export default {
		data() {
			return {
				data:{
					phone: '点击登录',
					balance: 0,
					profit: 0,
					total_num: 0,
					available_balance:0,
					silver:0,
					nextLevel:'无',
					self:0,
					euqs:0,
					show:true,
					self_profit:0,
					friend_profit:0,
					month_balance:0,
				},
				msg:'正在搜索设备',
				show1:false,
				barCode:'',
				show:false,
				sn:'',
				type:3,
				checked:false,
				list:[],
				level:0,
				levelName:'',
				jia:0,
				userid:"",
				yesnum:0,
				mushnum:0,
				adminid:0,
				waitmoney:0,
			}
		},
		computed:{
			// ...mapState({
			// 	loginStatus:state=>state.user.loginStatus,
			// 	userInfo:state=>state.user.userInfo
			// })
		},
		onLoad(option) {
			
		},
		onShow() {
			uni.hideShareMenu()
			this.sys = App.globalData.sys
			this.getInfo()
			// console.log(this.data.euqs)
		},
		methods: {
			eye:function(){
				this.show = !this.show;
				
			},
			
			goOrder(index){
				uni.setStorageSync('orderIndex',index);
				uni.navigateTo({
					// 跟‘/’非常重要！！否则小程序可以运行但找不到页面！！
					url:`/pages/mine/my-order/my-order?status=${index}`
				})
			},
			goConfig(){
				uni.navigateTo({
					url:('/pages/my-config/my-config')
				})
			},
			goLogin(){
				uni.navigateTo({
					url:('/pages/mine/login/login')
				})
			},
			signout(){
				uni.setStorageSync('userinfo','');
				uni.showToast({
					title:"退出成功",
					icon:"none"
				})
				 uni.removeStorageSync('userinfo');
				let userinfo = uni.getStorageSync('userinfo');
				// uni.switchTab({
				// 	url:`/pages/index/index`
				// })
				uni.clearStorage()
				uni.reLaunch({
					url:'/pages/mine/login/login'
				})
			},
			
			
			getInfo(){
				let userinfo = uni.getStorageSync('userinfo');
				uni.showLoading({
					title:"加载中"
				})
				this.$api.interfaceApi('getInfo')({
					'user_id':userinfo.id
				}).then(res=>{
					if(res.code == 200){
						this.data = res.data
						this.jia =parseFloat(res.data.self_profit*1+res.data.friend_profit*1).toFixed(2)
						this.level = res.data.level
						this.levelName = res.data.levelName
						if(res.data.self_profit==null){
							this.data.self_profit=0.00.toFixed(2)
						}
						console.log(this.data)
					}
					uni.hideLoading()
				})
			},
			toEqu(value,index){
				uni.setStorageSync('equValue',value);
				uni.setStorageSync('equIndex',index);
				uni.switchTab({
					url:`/pages/equipment/equipment`
				})
			},
			toZuo(){
				uni.navigateTo({
					// url:('/pages/mine/revenue-details?sum=${this.data.self}')
					url:`/pages/mine/revenue-details?sum=${this.data.self}`
				})
			},
			toZuoShare(){
				uni.navigateTo({
					url:`/pages/mine/share-details?sum=${this.data.self_profit}`
				})
			},
			togengduo(){
				uni.navigateTo({
					url:'/pages/mine/team'
				})
			},
			toGorule(){
				let userinfo = uni.getStorageSync('userinfo');
				uni.navigateTo({
					url:`/pages/mine/gorule`
				})
				
			},
		}
	}
</script>

<style>

	@import url("mine.css");
	@import url("../../common/uni.css")
</style>
